﻿package mortal.game.resource.tableConfig
{
    import Message.DB.Tables.*;
    import com.gengine.resource.*;
    import extend.language.*;
    import flash.utils.*;
    import mortal.game.cache.*;
    import mortal.game.view.common.*;

    public class MedalConfig extends Object
    {
        private var _medalDic:Dictionary;
        private var _medcatagoryDic:Dictionary;
        public var addPrivilegeArr:Array;
        private var _catagoryNum:int;
        private static var _instance:MedalConfig;

        public function MedalConfig()
        {
            this._medalDic = new Dictionary();
            this._medcatagoryDic = new Dictionary();
            this.addPrivilegeArr = ["bossExpAdd", "honorAdd", "arenaAdd", "exploitAdd"];
            if (_instance != null)
            {
                throw new Error(" MedalConfig 单例 ");
            }
            this.init();
            return;
        }// end function

        private function init() : void
        {
            var _loc_1:* = ConfigManager.instance.getJSONByFileName("t_medal.json");
            this.write(_loc_1);
            return;
        }// end function

        private function write(param1:Object) : void
        {
            var _loc_2:TMedal = null;
            var _loc_3:Object = null;
            for each (_loc_3 in param1)
            {
                
                _loc_2 = new TMedal();
                ClassTypesUtil.copyValue(_loc_2, _loc_3);
                this._medalDic[_loc_2.code] = _loc_2;
                if (this._medcatagoryDic[_loc_2.catagory] == null)
                {
                    this._medcatagoryDic[_loc_2.catagory] = new Dictionary();
                    var _loc_6:String = this;
                    var _loc_7:* = this._catagoryNum + 1;
                    _loc_6._catagoryNum = _loc_7;
                }
                if (this._medcatagoryDic[_loc_2.catagory][_loc_2.type] == null)
                {
                    this._medcatagoryDic[_loc_2.catagory][_loc_2.type] = new Array();
                }
                (this._medcatagoryDic[_loc_2.catagory][_loc_2.type] as Array).push(_loc_2);
            }
            return;
        }// end function

        public function get totalMedalNum() : int
        {
            var _loc_1:int = 0;
            var _loc_3:TMedal = null;
            var _loc_2:* = Cache.instance.role.entityInfo.level;
            for each (_loc_3 in this._medalDic)
            {
                
                if (_loc_3.typeLevel == 1 && _loc_2 >= _loc_3.roleLevel)
                {
                    _loc_1++;
                }
            }
            return _loc_1;
        }// end function

        public function get catagoryNum() : int
        {
            return this._catagoryNum;
        }// end function

        public function getTmedalByCode(param1:int) : TMedal
        {
            return this._medalDic[param1];
        }// end function

        public function get medcatagoryDic() : Dictionary
        {
            return this._medcatagoryDic;
        }// end function

        public function getMedCatagoryArrByCatagory(param1:int) : Dictionary
        {
            return this._medcatagoryDic[param1];
        }// end function

        public function translateValueName(param1:String) : String
        {
            var _loc_2:String = null;
            switch(param1)
            {
                case "bossExpAdd":
                {
                    _loc_2 = Language.getString(20596);
                    break;
                }
                case "honorAdd":
                {
                    _loc_2 = Language.getString(20597);
                    break;
                }
                case "arenaAdd":
                {
                    _loc_2 = Language.getString(20598);
                    break;
                }
                case "exploitAdd":
                {
                    _loc_2 = Language.getString(20599);
                    break;
                }
                default:
                {
                    break;
                }
            }
            return _loc_2;
        }// end function

        public static function get instance() : MedalConfig
        {
            if (_instance == null)
            {
                _instance = new MedalConfig;
            }
            return _instance;
        }// end function

    }
}
